pub fn new_count_distinct(input_str: &str) -> usize {
    let parts: Vec<&str> = input_str.split(',').collect::<Vec<_>>();
    let mut ht = HashTable::new(parts.len());
    for part in parts {
        ht.insert(part);
    }
    ht.get_count()
}

//实现一个散列表
struct HashTable<'a> {
    table: Vec<Option<&'a str>>,
    capacity: usize,
    count: usize,
}

impl<'a> HashTable<'a> {
    //实现一个散列函数
    fn hash(&self, s: &str) -> usize {
        s.chars().fold(0, |acc, c| acc + c as usize * c as usize) % self.capacity
    }
    fn new(capacity: usize) -> Self {
        HashTable {
            table: vec![None; 2 * capacity],
            capacity: capacity * 2,
            count: 0,
        }
    }

    fn insert(&mut self, s: &'a str) {
        let mut h = self.hash(s);
        let mut i: usize = 1; //这里需要实现一个循环，直到散列表中不存在这个字符串为止
        while self.table[h].is_some() {
            if self.table[h] == Some(s) {
                return;
            }
            h = (h + i * i) % self.capacity;
            i += 1;
        }
        self.table[h] = Some(s);
        self.count += 1;
    }

    fn get_count(&self) -> usize {
        self.count
    }
}
